import javax.print.DocFlavor;
import java.util.*;

public class work5 {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {5, 6, 6, 7, 7, 7,7, 7, 7, 8, 9,10,11};
        int target = 12;
    }
}


class Solution{
    public  int left = -1, right = -1;
    public  int target;
    public  int[] searchRange(int[] nums,int target) {
        this.target = target;
        if (nums == null || nums.length == 0 ){
            return new int[]{left,right};
        }
        binaryLeft(nums, 0, nums.length - 1);
        if (left != -1) {
            binaryRight(nums, left, nums.length - 1);
        }
        return new int[]{left,right};
    }

    public void binaryLeft(int[] nums, int left, int right) {
        if (left > right) {
            return;
        }
        if (nums[left] == target){
            this.left = left;
            return;
        }
        int mid = left + ((right - left) >> 1);
        if (nums[mid] >= target){
            binaryLeft(nums,left + 1,mid);
        }else {
            binaryLeft(nums,mid+1,right);
        }
    }

    public  void binaryRight(int[] nums, int left, int right) {
        if (left > right) {
            return;
        }
        if (nums[right] == target){
            this.right = right;
            return;
        }
        int mid = left + ((right - left) >> 1);
        if (nums[mid] <= target){
            binaryRight(nums,mid,right-1);
        }else {
            binaryRight(nums,left,mid - 1);
        }
    }
}